<template>
  <div>
    <el-container>
      <!--      侧边栏  网页宽度  背景色   -->
      <el-aside :width="asideWidth" style="min-height: 100vh; background-color: #001529">
        <!--        图标 + 哈利波特 居中对齐摆放   -->
        <div style="height: 60px;line-height: 60px; display: flex; align-items: center;
        justify-content: center;color: white">
          <img src="@/assets/mall-manage.png" alt="" style="width: 30px; height: 30px;">
          <span class="logo-title" v-show="!isCollapse">哈利波特</span>
        </div>
        <!--        侧边栏 选择列表  默认不收缩 关闭默认动态样式 通过路由访问每个单击列表项 -->
        <el-menu :collapse="isCollapse" :collapse-transition="false" style="border: none;"
                 :default-active="$route.path" router
                 background-color="#001529"
                 text-color="rgba(255,255,255,.65)" active-text-color="#fff">
          <el-menu-item index="/">
            <i class="el-icon-house"></i>
            <span slot="title">系统首页</span>
          </el-menu-item>
          <el-menu-item index="/1">
            <i class="el-icon-house"></i>
            <span slot="title">产品管理</span>
          </el-menu-item>
          <el-menu-item index="/2">
            <i class="el-icon-house"></i>
            <span slot="title">人员管理</span>
          </el-menu-item>
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>信息管理</span>
            </template>
            <el-menu-item>用户信息</el-menu-item>
            <el-menu-item>管理员信息</el-menu-item>
            <el-menu-item index="/111">成员信息</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>

      <el-container>
        <!--        图标 + 面包屑 + 用户信息 （全屏按钮+头像+用户名）-->
        <el-header>
          <i :class="collapseIcon" style="font-size: 26px" @click="handleCollapse"></i>
          <el-breadcrumb separator-class="el-icon-arrow-right" style="margin-left: 20px">
            <el-breadcrumb-item :to="{path: '/'}">首页</el-breadcrumb-item>
            <el-breadcrumb-item :to="{path: '/user'}">用户管理</el-breadcrumb-item>
          </el-breadcrumb>

          <div style="flex: 1;width: 0;display: flex; align-items: center; justify-content: flex-end">
            <i class="iconfont icon-quanping-01" style="font-size: 26px;color: black" @click="handleFull"></i>
            <el-dropdown placement="bottom">
              <div style="display: flex; align-items: center; cursor: default">
                <img src="@/assets/mall-manage.png" alt="" style="width: 40px; height: 40px; margin: 0 5px">
                <span>管理员</span>
              </div>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>个人信息</el-dropdown-item>
                <el-dropdown-item>修改密码</el-dropdown-item>
                <el-dropdown-item @click.native="$router.push('/login')">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </el-header>
        <!--        主页 引言+标签块     -->
        <el-main>
          <div style="box-shadow: 0 0 10px rgba(0,0,0,.1); padding: 10px 20px; border-radius: 5px"> 早安，骚年，祝你开心每一天
          </div>
          <div style="display:flex;margin-top: 10px">
            <el-card style="width: 50%; margin-right: 10px">
              <div class="clearfix" slot="header">
                <span>新手的毕设项目2024</span>
              </div>
              <div>
                2024毕设开始，手把手敲出来
                <div style="margin-top: 20px">
                  <div style="margin:10px 0">
                    <strong>主题色</strong>
                  </div>
                  <el-button type="primary" plain>按钮</el-button>
                  <el-button type="success" plain>按钮</el-button>
                  <el-button type="warning" plain>按钮</el-button>
                  <el-button type="danger" plain>按钮</el-button>
                  <el-button type="info" plain>按钮</el-button>
                </div>
              </div>
            </el-card>
            <el-card style="width: 50%">
              <div slot="header" class="clearfix">
                <span>渲染用户的数据</span>
              </div>
              <div>
                <el-table :data="users">
                  <el-table-column label="ID" prop="id"></el-table-column>
                  <el-table-column label="用户名" prop="username"></el-table-column>
                  <el-table-column label="姓名" prop="name"></el-table-column>
                  <el-table-column label="地址" prop="address"></el-table-column>
                </el-table>
              </div>
            </el-card>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>

import axios from "axios";
import request from "@/utils/request";

export default {
  name: 'HomeView',
  data() {
    return {
      isCollapse: false,
      asideWidth: "200px",
      collapseIcon: "el-icon-s-fold",
      users: []
    }
  },
  mounted() {
    // axios.get("http://localhost:8080/user/list").then(res => {
    //   console.log(res);
    //   this.users = res.data.data;
    // })
    request.get("/user/list").then(res => {
      console.log(res);
      this.users = res.data;
    })
  },
  methods: {
    // 激活收缩侧边栏的变化效果
    handleCollapse() {
      this.isCollapse = !this.isCollapse;
      this.asideWidth = this.isCollapse ? "64px" : "200px";
      this.collapseIcon = this.isCollapse ? "el-icon-s-fold" : "el-icon-s-unfold";
    },
    //网页全屏
    handleFull() {
      document.documentElement.requestFullscreen();
    }
  }
}
</script>

<style>

/*.el-menu--inline {
  background-color: #000c17 !important;
}*/

/*侧边栏标题下的子标题背景颜色*/
.el-menu--inline .el-menu-item {
  background-color: #000c17 !important;
  padding-left: 49px !important;
}

/*侧边栏一级目录和子目录的文字过渡色*/
.el-menu-item:hover, .el-submenu__title:hover {
  color: #fff !important;
}

/*侧边栏图标的过渡色*/
.el-submenu__title:hover i {
  color: #fff !important;
}

/*左侧激活的窗口*/
.el-menu-item.is-active {
  background-color: #1890ff !important;
  border-radius: 5px !important;
  /*margin: 4px;*/
  width: calc(100% - 8px);
  margin-left: 4px;
}

/*收缩侧边栏所对应的样式*/
.el-menu-item.is-active i, .el-menu-item.is-active .el-tooltip {
  margin-left: -4px;
}

/*每个目录的高度*/
.el-menu-item {
  /*margin: 4px !important;*/
  height: 40px !important;
  line-height: 40px !important;
}

.el-submenu__title {
  /*margin: 4px !important;*/
}

/*拥有子目录的下拉目录箭头位置*/
.el-submenu__icon-arrow {
  margin-top: -3px;
}

.el-submenu .el-menu-item {
  min-width: 0 !important;
}

.el-menu--inline .el-menu-item.is-active {
  padding-left: 45px !important;
}

/*侧边栏过渡动画*/
.el-aside {
  transition: width .3s;
  box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
}

/*网页标题logo样式*/
.logo-title {
  margin-left: 5px;
  font-size: 20px;
  transition: all .3s;
}

/*头部盒子样式*/
.el-header {
  box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
  display: flex;
  align-items: center;
}
</style>